home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Libraries
/
CPEditText 1.2
/
CPEditText.h
< prev
next >
Wrap
Text File
|
1993-10-03
|
8KB
|
211 lines
/******************************************************************************
CPEditText.h
Interface for the PEditText Class
SUPERCLASS = CAbstractText
Copyright © 1992-1993 Christopher R. Wysocki. All rights reserved.
******************************************************************************/
#pragma once // Include this file only once
/** Includes **/
#include <CAbstractText.h> // Interface for superclass
#include <Global.h>
#include "CPEditTextX.h" // Additional constants and macros
/** Compilation Constants **/
#define qTCL113 1 // Set to 1 if using TCL 1.1.3 or later
#define qPEUseInsertionGap 1 // Set to 0 to not use insertion gap buffer
/** Type Definitions **/
typedef enum { kBreakLeft, kBreakRight } BreakDirection;
/** Class Declaration **/
class CPEditText : public CAbstractText {
/** Instance Variables **/
protected:
Handle itsTextHandle; // Handle to text to display
long itsTextLength; // Length of text to display
long itsNumLines; // Number of lines in text
LongHandle itsLineStarts; // Offsets to starts of lines
#if qPEUseInsertionGap
long itsGapPosition; // Position of insertion gap
long itsGapLength; // Length of insertion gap
#endif
short itsTextFont; // Font family number for text
short itsTextSize; // Font size for text
Style itsTextFace; // Font style for text
short itsTextMode; // Transfer mode for text
long itsSpacingCmd; // Spacing command for text
short itsLineHeight; // Line height for text
short itsFontAscent; // Ascent for text
short itsMaxCharWidth; // Maximum width of character
short itsTabSpaces; // Number of spaces per tab
short itsTabWidth; // Number of pixels per tab
long itsSelStart; // Start of selection range
long itsSelEnd; // End of selection range
long itsSelAnchor; // Anchor of selection range
Boolean fReallyActive; // Is the pane really active?
Boolean fOutlineHilite; // Outline inactive selection range?
Boolean fUseItalicCaret; // Use italic caret/selection range?
Boolean fShowInvisibles; // Show invisible characters?
#if !qTCL113
Boolean scrollHoriz; // Scroll horizontally?
#endif
private:
long itsClickTime; // Time of last click
long itsCaretTime; // Time of last caret blink
long itsUpDownHOffset; // Last horiz pixel offset for up/down arrow
Boolean fCaretVisible; // Is the insertion caret visible?
Boolean fUpDownArrow; // Last action up/down arrow key?
/** Class Variables **/
protected:
static CursHandle cItalicIBeamCursor; // Italic i-beam cursor
static RgnHandle cSaveClipRgn; // Saved clipping region
/** Instance Methods **/
public:
/** Construction/Destruction **/
void IPEditText(CView *anEnclosure, CBureaucrat *aSupervisor,
short aWidth, short aHeight,
short aHEncl, short aVEncl,
SizingOption aHSizing, SizingOption aVSizing);
virtual void IViewTemp(CView *anEnclosure, CBureaucrat *aSupervisor,
Ptr viewData);
virtual void Dispose(void);
/** Display **/
virtual void Draw(Rect *area);
virtual void Activate(void);
virtual void Deactivate(void);
virtual void SetSelection(long selStart, long selEnd, Boolean redraw);
virtual void HideSelection(Boolean hide, Boolean redraw);
/** Scrolling **/
virtual void ScrollToSelection(void);
virtual void ScrollToOffset(long charOffset);
/** Cursor **/
virtual void AdjustCursor(Point where, RgnHandle mouseRgn);
virtual void Dawdle(long *maxSleep);
/** Mouse and Keystroke **/
virtual void DoClick(Point hitPt, short modifierKeys, long when);
virtual Boolean HitSamePart(Point pointA, Point pointB);
virtual void DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent);
virtual void TypeChar(char theChar, short theModifiers);
virtual void DoArrowKey(char theChar, short theModifiers);
/** Text Specification **/
virtual void SetTextPtr(Ptr textPtr, long numChars);
virtual void UseTextHandle(Handle textHandle);
virtual void InsertTextPtr(Ptr insertPtr, long insertLen, Boolean redraw);
virtual Handle CopyTextRange(long start, long end);
virtual void DeleteTextRange(long start, long end, Boolean redraw);
virtual void ReplaceTextRange(long start, long end, Ptr replacePtr, long replaceLen);
virtual void ReplaceSelection(Ptr replacePtr, long replaceLen);
virtual void PerformEditCommand(long theCommand);
/** Text Characteristics **/
virtual void SetFontNumber(short aFontNumber);
virtual void SetFontSize(short aSize);
virtual void SetFontStyle(short aStyle);
virtual void SetTextMode(short aMode);
virtual void SetAlignCmd(long anAlignment);
virtual long GetAlignCmd(void);
virtual void SetSpacingCmd(long aSpacingCmd);
virtual long GetSpacingCmd(void);
#if !qTCL113
void SetHorizontalScroll(Boolean doHoriz);
#endif
void SetTabSpaces(short tabSpaces);
short GetTabSpaces(void);
/** Display Characteristics **/
void SetOutlineHiliting(Boolean outlineHilite);
void SetItalicCaret(Boolean useItalicCaret);
void SetShowInvisibles(Boolean showInvisibles);
Boolean GetShowInvisibles(void);
/** Accessing **/
virtual void SetBounds(LongRect *aBounds);
#if qTCL113
virtual void GetSteps(short *hStep, short *vStep);
#endif
virtual Handle GetTextHandle(void);
#if qPEUseInsertionGap
Handle GetRawTextHandle(void);
#endif
virtual long GetHeight(long startLine, long endLine);
virtual long GetCharOffset(LongPt *aPt);
virtual void GetCharPoint(long offset, LongPt *aPt);
virtual void GetCharStyle(long charOffset, TextStyle *aStyle);
virtual void GetTextStyle(short *whichAttributes, TextStyle *aStyle);
virtual long FindLine(long charPos);
long GetLineStart(long line);
long GetLineEnd(long line);
short GetLineLength(long line);
virtual long GetLength(void);
virtual long GetNumLines(void);
virtual void GetSelection(long *selStart, long *selEnd);
short GetChar(long aPosition);
virtual void GetCharBefore(long *aPosition, tCharBuf charBuf);
virtual void GetCharAfter(long *aPosition, tCharBuf charBuf);
virtual Boolean GetWordBounds(long charPos, long *wordStart, long *wordEnd);
virtual void GetParagraphBounds(long charPos, long *paraStart, long *paraEnd);
#if qPEUseInsertionGap
long GetGapPosition(void);
long GetGapLength(void);
#endif
/** Hook Methods **/
virtual long WordBreakHook(long charPos, BreakDirection direction);
virtual void CaretHook(const Rect *caretRect);
virtual void HiliteHook(const Rect *hiliteRect);
/** Internal Methods **/
protected:
void IPEditTextX(void);
virtual void CreateEnvironment(void);
#if qPEUseInsertionGap
void SetGapPosition(long newGapPosition);
void SetGapLength(long newGapLength);
void CloseGap(void);
#endif
void CheckInsertion(Ptr insertPtr, long insertLen, Boolean useSelection,
long *numInsertCRs, long *numSelectionCRs);
long CountRangeCRs(long start, long end);
virtual void InsertText(Ptr insertPtr, long insertLen, long numInsertCRs, Boolean redraw);
virtual void DeleteText(long start, long end, long numDeleteCRs, Boolean redraw);
virtual void RefreshTextAfter(long afterPos, Boolean refreshOnlyLine);
virtual void DrawLineRange(long startLine, long endLine, long startLineOffset, Boolean erase);
virtual void HiliteTextRange(long start, long end);
virtual short GetTextWidth(long line, short startPos, short endPos);
virtual ShortHandle MeasureLineWidths(long line);
virtual ShortHandle MeasureTextWidths(long startPos, long endPos, short maxWidth);
virtual short ConvertInvisibles(Handle invisH, short numChars);
virtual void AdjustBounds(void);
virtual void CalcLineHeight(void);
virtual void CalcTabWidth(void);
virtual void CalcLineStarts(void);
virtual void AdjustLineStarts(long startChar, long numCharsDelta, long numLinesDelta);
void DrawCaret(void);
void ShowCaret(void);
void HideCaret(void);
void GetMacFontInfo(FontInfo *macFontInfo);
};